//
//  DFBaseViewController.m
//  cf
//
//  Created by lanou on 15/10/24.
//  Copyright © 2015年 xuzenghui. All rights reserved.
//

#import "DFBaseViewController.h"
#import "UIColor+DFThemeColor.h"
@interface DFBaseViewController ()

@end

@implementation DFBaseViewController

- (instancetype)init
{
    if (self = [super init]) {
        _topView = [[UIView alloc]initWithFrame:CGRectMake(0, 20,kScreenWidth ,44 )];
        _topView.backgroundColor = [UIColor themeColor];
        _backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _backBtn.frame = CGRectMake(15, 9, 26, 26);
        [_backBtn setImage:[UIImage imageNamed:@"fanhui"] forState:UIControlStateNormal];
        [_backBtn addTarget:self action:@selector(backToFront) forControlEvents:UIControlEventTouchUpInside];
        _titleLab = [[UILabel alloc]initWithFrame:CGRectMake(kScreenWidth / 2 - 50, 2, 100, 40)];
        _titleLab.textColor = [UIColor textColor];
        _titleLab.textAlignment = NSTextAlignmentCenter;
        [_topView addSubview:_titleLab];
    }
    return self;
}

- (void)backToFront
{
    CATransition* transition = [CATransition animation];
    transition.duration = 0.5;
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    transition.type = kCATransitionFade;//kCATransitionMoveIn;//kCATransitionFade;  //, kCATransitionPush, kCATransitionReveal
   // transition.subtype = kCATransitionFromTop; //kCATransitionFromLeft, kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromBottom
    [self.navigationController.view.layer addAnimation:transition forKey:nil];
    [self.navigationController popViewControllerAnimated:NO];
}


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
